package biznussoft.fieldservice360.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import biznussoft.fieldservice360.R;
import biznussoft.fieldservice360.model.MaterialModel;


public class MaterialMasterAdapter extends BaseAdapter{

	private ArrayList<MaterialModel> list;
	Context mContext;
	public MaterialMasterAdapter(Context conrtext,
			ArrayList<MaterialModel> MaterialList) {
		// TODO Auto-generated constructor stub
		list = MaterialList;
		mContext = conrtext;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public class ViewHolder{
		public TextView sno;
		public TextView type;
		public TextView duration;
		public TextView cost;
	}

	public View getView(int position, View v, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		ViewHolder holder;
		
		if(v == null){
			
			holder = new ViewHolder();
			LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inflator.inflate(R.layout.contact_listview, null);
			holder.sno  = (TextView) v.findViewById(R.id.tvContactLastName);
			holder.type = (TextView) v.findViewById(R.id.tvContactPhone);
			holder.duration  = (TextView) v.findViewById(R.id.tvContactTitle);
			holder.cost = (TextView) v.findViewById(R.id.tvContactEmail);
			
			v.setTag(holder);
		}else{
			holder = (ViewHolder) v.getTag();
		}
		
		MaterialModel bean = list.get(position);
		
		
		holder.sno.setText(bean.getAction());
		holder.duration.setText(bean.getItemId());
		holder.type.setText(bean.getQuantity());
		holder.cost.setText(bean.getNetPay());
		
		return v;
	}


}
